package com.lagou.consumer;

import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.io.IOException;

/**
 * 主函数
 * @author 陶肖寅
 * @version V1.0
 * @Package com.lagou.consumer
 * @email fromlx@126.com
 * @date 2020-04-16 23:30
 * @Copyright © 2020-2021 城云科技(中国)有限公司
 */
public class ConsumerMain {
    public static void main(String[] args) throws IOException {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start();
        ConsumerComponent service = context.getBean(ConsumerComponent.class);
        MonitorConsumer monitorConsumer = context.getBean(MonitorConsumer.class);
        while (true){
            System.in.read();
            try {
                String hello = service.sayHello("world");
                System.out.println("result :" + hello);
                monitorConsumer.monitor();

            } catch (Exception e) {
                e.printStackTrace();
            }

        }

    }
    @Configuration
    @PropertySource("classpath:/dubbo-consumer.properties")
    @ComponentScan(value = {"com.lagou.consumer"})
    @EnableDubbo(scanBasePackages = "com.lagou.consumer")
    static class ConsumerConfiguration {

    }
}
